package com.app.view.zoon;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.widget.ImageView;

import com.app.view.R;

public class MainActivity extends AppCompatActivity {

    private FreezView freezView;
    private ImageView circleImageView;
    private HookOrForkView hookOrForkView;
    private int drawHookViewW = 0;//    勾或者叉的view 的起始宽度
    private int drawHookViewH = 0;//    勾或者叉的view 的起始高度

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        freezView = findViewById(R.id.freezView);
        circleImageView = findViewById(R.id.iv_bind_normal);
        hookOrForkView = findViewById(R.id.hookorforkview);
        hookOrForkView.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
            @Override
            public boolean onPreDraw() {
                hookOrForkView.getViewTreeObserver().removeOnPreDrawListener(this);
                ViewGroup.LayoutParams drawHookViewLayoutParams = hookOrForkView.getLayoutParams();
                drawHookViewW = drawHookViewLayoutParams.width;
                drawHookViewH = drawHookViewLayoutParams.height;
                return false;
            }
        });
    }

    public void initView() {
        //先显示动画扩散的布局进行搜索
//      resultUI(SCANING_STATE);
//      circleImageView.setImageResource(R.mipmap.ic_bluetooth_yellower);
    }

    @Override
    protected void onResume() {
        super.onResume();
        if (!freezView.isAnima()) {
            freezView.startAnima();

        }
    }


//    /**
//     * 显示UI布局
//     *
//     * @param state
//     */
//    protected void resultUI(int state) {
//        if (state == SCANING_STATE) {
//            //先显示动画扩散的布局进行搜索
//
//            hookOrForkView.setVisibility(View.GONE);
//        } else if (state == LIST_DATA_STATE) {
////            llList.setVisibility(View.VISIBLE);
////            tryBtn.setVisibility(View.INVISIBLE);
////            flAnimLayout.setVisibility(View.GONE);
////        } else if (state == SCAN_FAILED_STATE) {
//            //没有扫描到设备，显示打叉布局
//
//            hookOrForkView.setVisibility(View.VISIBLE);
//            int scaleW = ScreenUtils.initScreen(MainActivity.this).dp2px(20);
//            ViewGroup.LayoutParams drawHookViewLayoutParams = hookOrForkView.getLayoutParams();
//            drawHookViewLayoutParams.width = drawHookViewW + 2 * scaleW;
//            drawHookViewLayoutParams.height = drawHookViewH + 2 * scaleW;
//            hookOrForkView.setLayoutParams(drawHookViewLayoutParams);
//            hookOrForkView.setIsdrawtrue(false);
//            hookOrForkView.startAnima();
//        }
//    }
}
